﻿namespace NEvoWeb.Modules.NB_Store
{
    using DotNetNuke.Common;
    using DotNetNuke.Entities.Portals;
    using DotNetNuke.Services.Localization;
    using System;
    using System.Runtime.CompilerServices;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    public class ShowSelectLang : UserControl
    {
        [AccessedThroughProperty("phFlag")]
        private PlaceHolder _phFlag;

        private void buildMenu()
        {
            if (DotNetNuke.Services.Localization.Localization.GetEnabledLocales().Count > 1)
            {
                string currentCulture = SharedFunctions.getStoreCookieValue(PortalController.GetCurrentPortalSettings().PortalId, "AdminLang", "AdminSelectedCulture");
                if (currentCulture == "")
                {
                    currentCulture = SharedFunctions.GetCurrentCulture();
                }
                if (currentCulture != "None")
                {
                    this.phFlag.Controls.Add(new LiteralControl("<img src=\"" + Globals.ResolveUrl("~/images/flags/" + currentCulture + ".gif") + "\" height=\"12\" width=\"18\" border=\"0\" />"));
                }
            }
        }

        public void Refresh()
        {
            this.buildMenu();
        }

        protected virtual PlaceHolder phFlag
        {
            get
            {
                return this._phFlag;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._phFlag = value;
            }
        }
    }
}

